<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * Game控制器
 */
class Game extends AdminBase
{
    
    /**
     * Game列表
     */
    public function GameList()
    {
        
        $where = $this->logicGame->getWhere($this->param);
        
        $this->assign('list', $this->logicGame->getGameList($where, 'a.*', 'a.create_time desc'));
        $this->assign('game_category_list', $this->logicGame->getGameCategoryList([], 'id,name', '', false));
        $this->assign('param',$this->param);
        return $this->fetch('game_list');
    }
    
    /**
     * Game添加
     */
    public function GameAdd()
    {
        
        $this->GameCommon();
        $this->assign('game_category_list', $this->logicGame->getGameCategoryList([], 'id,name', '', false));
        return $this->fetch('game_edit');
    }
    
    /**
     * Game编辑
     */
    public function GameEdit()
    {
        
        $this->GameCommon();

        $info = $this->logicGame->getGameInfo(['a.id' => $this->param['id']], 'a.*');

        !empty($info) && $info['img_ids_array'] = str2arr($info['img_ids']);
        $this->assign('info', $info);
        $this->assign('game_category_list', $this->logicGame->getGameCategoryList([], 'id,name', '', false));
        return $this->fetch('game_edit');
    }
    
    /**
     * Game添加与编辑通用方法
     */
    public function GameCommon()
    {
        
        IS_POST && $this->jump($this->logicGame->GameEdit($_POST));
        

    }
    

   /**
     * 数据状态设置
     */
    public function excel()
    {

        IS_POST && $this->jump($this->logicGame->excel( $this->param));
        return $this->fetch('excel');
    }
    

    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('game', $this->param));
    }


    /**
     * 游戏分类添加
     */
    public function gameCategoryAdd()
    {

        IS_POST && $this->jump($this->logicgame->gameCategoryEdit($this->param));


        return $this->fetch('game_category_edit');
    }

    /**
     * 游戏分类编辑
     */
    public function gameCategoryEdit()
    {

        IS_POST && $this->jump($this->logicgame->gameCategoryEdit($this->param));

        $info = $this->logicgame->getgameCategoryInfo(['id' => $this->param['id']]);

        $this->assign('info', $info);

        return $this->fetch('game_category_edit');
    }

    /**
     * 游戏分类列表
     */
    public function gameCategoryList()
    {

        $this->assign('list', $this->logicgame->getgameCategoryList());

        return $this->fetch('game_category_list');
    }

    /**
     * 游戏分类删除
     */
    public function gameCategoryDel($id = 0)
    {

        $this->jump($this->logicgame->gameCategoryDel(['id' => $id]));
    }

    /**
     * 数据状态设置
     */
    public function update_info()
    {

        $this->jump($this->logicgame->update_info( $this->param));
    }
}
